from django.db import models

#0.用户基本信息
class Info(models.Model):
    userNo = models.CharField(max_length=32)
    pwd = models.CharField(max_length=20)
    gender = models.BooleanField()
    birthday = models.DateField('YYYY-MM-DD')
    province = models.CharField(max_length=20)
    major = models.CharField(max_length=20)  #专业
    academy = models.CharField(max_length=20)#学院
    clsName = models.CharField(max_length=20)
    userName = models.CharField(max_length=20, null=True)
    isTeacher = models.BooleanField(default=False)

#1.班级类
class Classes(models.Model):
    clsId = models.CharField('ID', primary_key=True, max_length=20)
    clsName = models.CharField(max_length=36)

# #2.学生类
# class Student(models.Model):
#     stuId = models.CharField('ID', primary_key=True, max_length=20)
#     cls = models.ForeignKey('Classes', on_delete=models.CASCADE)


#3.教师类
# class Teacher(models.Model):
#     teaId = models.CharField('ID', primary_key=True, max_length=20)
#     datum = models.ForeignKey('Datum', on_delete=models.CASCADE)
#     cls = models.ForeignKey('Classes', on_delete=models.CASCADE)


# #4.课程类
# class Course(models.Model):
#     couserId = models.CharField('ID', primary_key=True, max_length=20)
#     courseName = models.CharField(max_length=32)
#     questionAddress = models.CharField(max_length=32)  #课程答疑地址
#     examAddress = models.CharField(max_length=32)     #考试地址
#     teacher = models.ForeignKey('Teacher', on_delete=models.CASCADE)
#     student = models.ForeignKey('Student', on_delete=models.CASCADE)

#5.分数类
class Score(models.Model):
    stuId = models.CharField(max_length=32)
    score = models.IntegerField(3)
    cls = models.ForeignKey('Classes', on_delete=models.CASCADE)
    subject = models.ForeignKey('Suject', on_delete=models.CASCADE)
    name = models.CharField(max_length=32)
    questionAddress = models.CharField(max_length=32)
    xx = models.CharField(max_length=32)

# #6.资料表
# class Datum(models.Model):
#     datumName = models.CharField(max_length=32)
#     datumAddress = models.CharField(max_length=32)
#7.测试表
class ExamBank(models.Model):
    title = models.CharField(max_length=1000)
    A = models.CharField(max_length=1000)
    C = models.CharField(max_length=1000)
    B = models.CharField(max_length=1000)
    D = models.CharField(max_length=1000)
    right = models.CharField(max_length=2)
    subject = models.ForeignKey('Suject', on_delete=models.CASCADE)
    userNo = models.CharField(max_length=32)

# 学科
class Suject(models.Model):
    subId = models.CharField('ID', primary_key=True, max_length=20)
    subName = models.CharField(max_length=36)

# 测试类
class Test(models.Model):
    examName = models.CharField(max_length=32)
    stuId = models.CharField(max_length=32)
    stuSelect = models.CharField(max_length=1)
    correctSelect = models.CharField(max_length=1)
    subId = models.CharField(max_length=20)
    index = models.IntegerField()
    title = models.CharField(max_length=1000)
    A = models.CharField(max_length=1000)
    C = models.CharField(max_length=1000)
    B = models.CharField(max_length=1000)
    D = models.CharField(max_length=1000)

# 发布测试
class ReleaseTest(models.Model):
    subject = models.ForeignKey('Suject', on_delete=models.CASCADE)
    name = models.CharField(max_length=200)
    clz = models.ForeignKey('Classes', on_delete=models.CASCADE)
    isTestFinish = models.BooleanField(default=False)
    start = models.DateField('YYYY-MM-DD')
    end = models.DateField('YYYY-MM-DD')
    teacher = models.CharField(max_length=32)

# 答疑
class Answer(models.Model):
    subject = models.ForeignKey('Suject', on_delete=models.CASCADE)
    info = models.ForeignKey('Info', on_delete=models.CASCADE)
    problem = models.CharField(max_length=420)
    time = models.DateField('YYYY-MM-DD')

# 回复
class Comment(models.Model):
    info = models.ForeignKey('Info', on_delete=models.CASCADE)
    answer = models.ForeignKey('Answer', on_delete=models.CASCADE)
    time = models.DateField('YYYY-MM-DD')
    content = models.CharField(max_length=1000)

# 作业
class HomeWord(models.Model):
    """
        assignment:任务
        clsName：班级名称
        start：开始时间
        end：结束时间
        teacherNo:教师学号
        isFinish:是否结束
    """
    assignment = models.CharField(max_length=420)
    clz = models.ForeignKey('Classes', on_delete=models.CASCADE)
    start = models.DateField('YYYY-MM-DD')
    end = models.DateField('YYYY-MM-DD')
    teacherNo = models.CharField(max_length=32)
    isFinish = models.BooleanField(default=False)
    subject = models.ForeignKey('Suject', on_delete=models.CASCADE)
    a =models.CharField(max_length=32)
    b = models.CharField(max_length=32)
# 作业提交
class FinishWord(models.Model):
    homeWord = models.ForeignKey('HomeWord', on_delete=models.CASCADE)
    stuNo = models.CharField(max_length=32)
    answer = models.CharField(max_length=600)
    submitTime = models.DateTimeField('YYYY-MM-DD HH:MM:ss')
    clsName = models.CharField(max_length=36)
    isFinish = models.BooleanField(default=False)
    subName = models.CharField(max_length=32)
    a = models.CharField(max_length=32)
    b = models.CharField(max_length=32)